<!DOCTYPE html>
<html>
	{include file="public/_header" /}
	<body>
		<div class="layui-fluid">
				<div class="layui-row layui-col-space15">
					<div class="layui-col-md12">
						<div class="layui-card">
							<div class="layui-card-body ">
								<form class="layui-form" action="" lay-filter="type">
								  <div class="layui-form-item">
								    <label class="layui-form-label">类别名称</label>
								    <div class="layui-input-inline">
								      <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="类别名称" class="layui-input">
								    </div>
								  </div>
								  <div class="layui-form-item">
								    <label class="layui-form-label">描述</label>
								    <div class="layui-input-inline">
								      <input type="text" name="description" lay-verify="required" lay-reqtext="请输入类别描述" placeholder="请输入" autocomplete="off" class="layui-input">
								    </div>
								  </div>
								  <div class="layui-form-item">
								  	<label class="layui-form-label">排序</label>
								  	<div class="layui-input-inline">
								  		<input type="number" name="lsort" value="100" required lay-verify="required" placeholder="排序" autocomplete="off"
								  		 class="layui-input">
								  	</div>
								  </div>
								  <div class="layui-form-item">
								    <div class="layui-input-block">
								      <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
								    </div>
								  </div>
								</form>
								
							</div>
						</div>
					</div>
				</div>
			</div>
			<script type="text/javascript">
				$(function(){
					
					layui.use('form', function(){
					  var form = layui.form;
					  //表单初始赋值
					  var id = {$Request.get.id};
					  $.get("{:url('admin/Banner/banner_type_edit')}", {id:id}, function(res) {
					  	form.val('type', {
					  	  "name": res.data.name,
					  	  "lsort": res.data.lsort,
					  	  "description": res.data.description
					  	})						
					  })
					  //监听提交
					  form.on('submit(demo1)', function(obj){
						  obj.field.id = id;
						var lfc = top.layerFrameConfig;
						var iframeBIndex = lfc.iframeB.layer_index;
						var iframeCIndex = lfc.iframeC.index;
						var tableInfo = lfc.iframeC.info;
						$.post("{:url('admin/Banner/banner_type_edit')}",obj.field,function(res){
							if(res.status == 1){
								layer.msg('修改成功', {
									icon: 1,
									time: 300
								}, function() {
									parent.layer.close(iframeCIndex);
									tableInfo.reload()
								});
							}else{
								layer.msg(res.message)
							}
						})
					    return false;
					  });
					});
					
					
				})
				
			</script>
			
	</body>
</html>
